﻿using System;
using Microsoft.Xna.Framework;

namespace SoSlam.Common.ClientLogic
{
	public class TrackingCamera : GameComponent
	{
		private readonly World _world;

		private Vector2 _position;

		public Vector2 Position { get { return _position; } }

		public Rectangle Fov { get { return new Rectangle(0, 0, Game.GraphicsDevice.Viewport.Width, Game.GraphicsDevice.Viewport.Height); } }

		public TrackingCamera(Game game, World world)
			: base(game)
		{
			_world = world;
		}

		public override void Initialize()
		{
			_position = new Vector2(0, 0);

			base.Initialize();
		}

		public override void Update(GameTime gameTime)
		{
			base.Update(gameTime);
		}

		public void AimAt(Vector2 targetPosition)
		{
			_position = targetPosition - new Vector2(Game.GraphicsDevice.Viewport.Width / 4f, Game.GraphicsDevice.Viewport.Height / 4f);
			_position = Vector2.Clamp(_position, new Vector2(-(float)Game.GraphicsDevice.Viewport.Width / 6, /*-Game.GraphicsDevice.Viewport.Height + 20*/ int.MinValue), new Vector2(int.MaxValue, -Game.GraphicsDevice.Viewport.Height + 20));
		}
	}
}
